package com.aphrodite.io.sdp;

import com.aphrodite.util.StringParser;

/**
 * SDP origin field.
 * <p>
 * <BLOCKQUOTE>
 * 
 * <PRE>
 *    origin-field = &quot;o=&quot; username SP sess-id SP sess-version SP
 *                        nettype SP addrtype SP unicast-address CRLF
 * </PRE>
 * 
 * </BLOCKQUOTE>
 */
public final class OriginField extends SdpField {
	/** Creates a new OriginField. */
	public OriginField(SdpField sf) {
		super(sf);
	}

	/** Creates a new OriginField. */
	public OriginField(String origin) {
		super('o', origin);
	}

	/** Creates a new OriginField. */
	public OriginField(String username, String sess_id, String sess_version, String address) {
		super('o', username + " " + sess_id + " " + sess_version + " IN IP4 " + address);
	}

	/** Creates a new OriginField. */
	public OriginField(String username, String sess_id, String sess_version, String addrtype, String address) {
		super('o', username + " " + sess_id + " " + sess_version + " IN " + addrtype + " " + address);
	}

	/** Gets the address. */
	public String getAddress() {
		return (new StringParser(value)).skipString().skipString().skipString().skipString().skipString().getString();
	}

	/** Gets the address type. */
	public String getAddressType() {
		return (new StringParser(value)).skipString().skipString().skipString().skipString().getString();
	}

	/** Gets the session id. */
	public String getSessionId() {
		return (new StringParser(value)).skipString().getString();
	}

	/** Gets the session version. */
	public String getSessionVersion() {
		return (new StringParser(value)).skipString().skipString().getString();
	}

	/** Gets the user name. */
	public String getUserName() {
		return (new StringParser(value)).getString();
	}

}
